﻿<?php

require_once "context/MySpaceContext.php";
require_once "Api/RestV1.php";
require_once "Api/RestV9.php";
require_once "Api/OpenSearch.php";
require_once "Api/RealStream.php";
require_once "Api/PortableContact.php";
require_once "config/MySpaceUtils.php";
require_once "config/MySpaceException.php";
require_once(dirname(__FILE__)."/../OAuth/OAuth.php");


class MySpace {
  
  // public MySpaceContext
  public $context = NULL;
  
  // REST EndPoint objects
  public $restV9 = NULL;
  public $restV1 = NULL;
  public $opensearch = NULL;
  public $realStream = NULL;
  public $portableContact = NULL;
  /**
   * Sets up the MySpaceID API with your credentials
   *
   * @param String $consumerKey
   * @param String $consumerSecret
   * @param String $oAuthToken
   * @param String $oAuthTokenSecret
   * @return object a new myspace object
   */
   public function __construct($consumerKey,
		       $consumerSecret,
		       $oAuthToken = null,
		       $oAuthTokenSecret = null,
		       $isOffsite = true,
		       $authorized_verifier = '')  {
    
    $this->context = new MySpaceContext($consumerKey, $consumerSecret, $oAuthToken, $oAuthTokenSecret, $isOffsite, $authorized_verifier);
    $this->restV9 = new RestV9($this->context);
    $this->restV1 = new RestV1($this->context);
    $this->opensearch = new OpenSearch($this->context);
    $this->realStream = new RealStream($this->context);
    $this->portableContact = new PortableContact($this->context);
  }
  
   /*
   *  OpenSocial v0.9 ProfileComments
   *  Resource: http://opensocial.myspace.com/roa/09/profilecomments/@me/@self
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_ProfileComments
   *  Description: Get the User Profile Comments
   *  @param mixed  $personId  current Person Id
   *  @param string $fields    By default, the id of the comment author will be added to the result set, 
   *  						   give the fields=author to get more information on the author
   *  @return object of php object representing the JSON which is list of the current user's profile comments
   */
  
  public function getProfileComments($personId, $fields = NULL){
  	return $this->restV9->getProfileComments($personId, $fields);
  }
  
  /*
   *  OpenSocial v0.9 Ablums
   *  Resource: http://opensocial.myspace.com/roa/09/albums/@supportedFields
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Albums
   *  Description:  Get Album Supported Fields
   *  @return object of php object representing the JSON which is list of the album supported fields
   */ 
  
  public function getAlbumsSupportedFields(){
  	return $this->restV9->getAlbumsSupportedFields();
  }
  
  /*
   *  OpenSocial v0.9 Ablums
   *  Resource: http://opensocial.myspace.com/roa/09/albums/@me/@self
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Albums
   *  Description:  Get user albums
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        set the specific fields here
   *  @return object of php object representing the JSON which is list of the current user's albums
   */
  
   public function getAlbums($personId, $startIndex=1, $count=20, $fields=NULL){
   	 return $this->restV9->getAlbums($personId, $startIndex, $count, $fields);
   }
   
   /*
   *  OpenSocial v0.9 Ablums
   *  Resource: http://opensocial.myspace.com/roa/09/albums/@me/@self/{albumId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Albums
   *  Description:  Get user album By Album  Id
   *  @param mixed   $personId      current Person Id
   *  @param string  $ablumId	    album id of the album
   *  @param string  $fields        set the specific fields here
   *  @return object of php object representing the JSON which is list of the specific user album
   */
  
  public function getAlbum($personId, $albumId, $fields=NULL){
  	return $this->restV9->getAlbum($personId, $albumId, $fields);
  }
  
  /*
   *  OpenSocial v0.9 Ablums
   *  Resource: http://opensocial.myspace.com/roa/09/albums/@me/@self/{albumId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Albums
   *  Description:  Add the Album
   *  @param mixed   $personId      current Person Id
   *  @param string  $caption	    title of the album
   *  @param string  $private       privacy 'EveryOne | FriendsOnly | Me'
   *  @param string  $location      location of the album
   *  @return object of php object representing the url of the newly created album
   */
  
  public function addAlbum($personId, $caption, $private='Everyone', $location=NULL){
  	return $this->restV9->addAlbum($personId, $caption, $private, $location);
  }
  
  /*
   *  OpenSocial v0.9 Ablums
   *  Resource: http://opensocial.myspace.com/roa/09/albums/@me/@self/{albumId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Albums
   *  Description:  Update the Album
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $albumId       album Id of the album
   *  @param string  $caption	    title of the album
   *  @param string  $location		location of the album
   *  @return object of php object representing the url of the updated album
   */
  
  public function updateAlbum($personId, $albumId, $caption, $location=NULL){
  	return $this->restV9->updateAlbum($personId, $albumId, $caption, $location);
  }
  
  /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Get the Media Items Supported Fields
   *  @return object of php object representing the JSON which is list of supported fields
   */
  
  public function getMediaItemSupportedFields(){
  	return $this->restV9->getMediaItemSupportedFields();
  }
  
  /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@me/@self/{albumId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Get the Media Items By AlbumId
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $albumId       album Id of the album
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        set the specific fields here
   *  @return object of php object representing the JSON which is list of the specific user media items
   */
  
  public function getMediaItems($personId, $albumId, $startIndex=1, $count=20, $fields=NULL){
    return $this->restV9->getMediaItems($personId, $albumId, $startIndex, $count, $fields);
  }
  
  /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@me/@self/{albumId}/{menuItemId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Get the Media Items By Album ID and MenuItemId
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $albumId       album Id of the album
   *  @param mixed   @menuItemId    menuItemId 
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        set the specific fields here
   *  @return object of php object representing the JSON which is list of the specific user media Items
   */
  
  public function getMediaItemById($personId, $albumId, $menuItemId, $startIndex=1, $count=20, $fields=NULL){
  	return $this->restV9->getMediaItemById($personId, $albumId, $menuItemId, $startIndex, $count, $fields);
  }
  
  /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@me/@self/{albumId}/
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Add Photo
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $albumId       album Id of the album
   *  @param string  @caption       title of the picture
   *  @param integer $filePath      file path of the photo
   *  @return object of php object representing the url of newly created photo
   */
  
  public function addPhoto($personId, $albumId, $caption, $filePath) {
  	return $this->restV9->addPhoto($personId, $albumId, $caption, $filePath);
  }
  
   /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@me/@self/{albumId}/
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Add Video
   *  @param mixed   $personId      current Person Id
   *  @param string  $caption       title of the video
   *  @param string  $description   description of the video
   *  @param string  $tags			video tags
   *  @param string  $language		language
   *  @param integer $filePath      file path of the video
   *  @return object of php object representing the url of newly created photo
   */
  
  public function addVideo($personId, $caption, $description,  $filePath, $tags=NULL, $msCategories=NULL, $language='en-US') {
  	  return $this->restV9->addVideo($personId, $caption, $description,  $filePath, $tags, $msCategories, $language);
  }
  
   /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Get the Videos Supported Categories
   *  @return object of php object representing the JSON which is list of supported fields
   */
  
  public function getVideosCategories($personId){
  	return $this->restV9->getVideosCategories($personId);
  }
  
  /*
   *  OpenSocial v0.9 MediaItems
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItems/@supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_0.9_MediaItems
   *  Description:  Get the Videos Supported Categories by category Id
   *  @return object of php object representing the JSON which is list of supported fields
   */
  
  public function getVideosCategoriesById($personId, $categoryId){
  	return $this->restV9->getVideosCategoriesById($personId, $categoryId);
  }
  
  /*
   *  OpenSocial v0.9 MediaItemComments
   *  Resource: http://opensocial.myspace.com/roa/09/mediaItemcomments/@me/@self/{albumId}/{menuItemId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_MediaItemComments
   *  Description:  Get Media Item Comments
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $albumId       album Id of the album
   *  @param mixed   $menuItem	    specific menuItem Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param integer $filePath      file path of the photo
   *  @return object of php object representing the JSON which is list of the specific user album
   */
  
  public function getMediaItemComments($personId, $albumId, $menuItemId, $startIndex=1, $count=20, $fields=NULL){
  	return $this->restV9->getMediaItemComments($personId, $albumId, $menuItemId, $startIndex, $count, $fields);
  }
  
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Get Activities Supported Fields
   *  @return object of php object representing the JSON which is list of activities supported fields
   */
  
  public function getActivitiesSupportedFields(){
  	return $this->restV9->getActivitiesSupportedFields();
  }
  
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@supportedVerbs?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Get Activities Supported Verbs
   *  @return object of php object representing the JSON which is list of activities supported verbs
   */
  
  public function getActivitiesSupportedVerbs(){
  	return $this->restV9->getActivitiesSupportedVerbs();
  }
  
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@supportedObjectTypes?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Get Activities Supported Object
   *  @return object of php object representing the JSON which is list of activities supported object types
   */
  
  public function getActivitiesSupportedTypes(){
  	return $this->restV9->getActivitiesSupportedTypes();
  }
    
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@me/@self/{appId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Get user Activities by application Id
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $appId         specific application Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $updatedSince  Indicates the date before which no activities should be returned
   *  @return object of php object representing the JSON which is list of current user activities
   */
  
  public function getActivitiesByAppId($personId, $appId, $startIndex=1, $count=20, $fields=NULL, $updatedSince=NULL){
    return $this->restV9->getActivitiesByAppId($personId, $appId, $startIndex, $count, $fields, $updatedSince);
  }
  
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@me/@friends/{appId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Get Friend Activities by application Id
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $appId         specific application Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $updatedSince  Indicates the date before which no activities should be returned
   *  @return object of php object representing the JSON which is list of current user friend activities
   */
  
  public function getFriendActivitiesByAppId($personId, $appId, $startIndex=1, $count=20, $fields=NULL, $updatedSince=NULL){
    return $this->restV9->getActivitiesByAppId($personId, $appId, $startIndex, $count, $fields, $updatedSince);
  }
  
  /*
   *  OpenSocial v0.9 Activities
   *  Resource: http://opensocial.myspace.com/roa/09/activities/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Activities
   *  Description:  Create Activity
   *  @param mixed         $personId         current Person Id
   *  @param mixed         $externalId       external Id
   *  @param integer       $title            title of the activity
   *  @param integer       $body		     body of the activity
   *  @param dictionary    $templateParams   Dictionary parameter
   *  @param string        $titleid          titleId of the activity
   *  @return object of php object representing the url of newly created activity
   */
  
  public function createActivity($personId, $externalId, $title, $body, $templateParams, $titleId){
  	return $this->restV9->createActivity($personId, $externalId, $title, $body, $templateParams, $titleId);
  }
  
  /*
   *  OpenSocial v0.9 AppData
   *  Resource: http://opensocial.myspace.com/roa/09/appdata/@me/@self/{$appId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_AppData
   *  Description:  add/update App Data
   *  @param mixed     $personId         current Person Id
   *  @param mixed     $appId            application Id
   *  @param integer   $key              specific key
   *  @param integer   $value		     specific value
   *  @return object of php object representing the app data
   */
  
  public function addAppData($personId, $appId, $key, $value) {
  	return $this->restV9->addAppData($personId, $appId, $key, $value);
  }
  
  /*
   *  OpenSocial v0.9 AppData
   *  Resource: http://opensocial.myspace.com/roa/09/appdata/@me/@self/{$appId}
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_AppData
   *  Description:  Get App Data
   *  @param mixed     $personId         current Person Id
   *  @param mixed     $appId            application Id
   *  @param integer   $key              specific key
   *  @param integer   $value		     specific value
   *  @return object of php object representing the JSON which is list of app data
   */
  
  public function getAppData($personId, $appId, $key=NULL, $value=NULL) {
  	return $this->restV9->getAppData($personId, $appId, $key, $value);
  }
  
  /*
   *  OpenSocial v0.9 AppData
   *  Resource: http://opensocial.myspace.com/roa/09/appdata/@me/@self/{$appId}?fields=key
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_AppData
   *  Description:  Delete App Data
   *  @param mixed     $personId         current Person Id
   *  @param mixed     $appId            application Id
   *  @param string    $keys             semicolon separated keys to clear
   *  @return true on success, false on failure
   */
  
  public function clearAppData($personId, $appId, $keys) {
  	return $this->restV9->clearAppData($personId, $appId, $keys);
  }
  
  /*
   *  OpenSocial v0.9 Groups
   *  Resource: http://opensocial.myspace.com/roa/09/groups/@me?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Groups
   *  Description:  Get Groups
   *  @param mixed     $personId         current Person Id
   *  @return object of php object representing the JSON which is list of current user groups
   */
  
  public function getGroups($personId){
  	return $this->restV9->getGroups($personId);
  }
  
  /*
   *  OpenSocial v0.9 Groups
   *  Resource: http://opensocial.myspace.com/roa/09/groups/supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Groups
   *  Description:  Get Groups Supported Fields
   *  @return object of php object representing the JSON which is list of groups supported fields
   */
  
  public function getGroupsSupportedFields(){
  	return $this->restV9->getGroupsSupportedFields();
  }
  
  /*
   *  OpenSocial v0.9 People
   *  Resource: http://opensocial.myspace.com/roa/09/people/supportedFields?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_People
   *  Description:  Get People Supported Fields
   *  @return object of php object representing the JSON which is list of people supported fields
   */
  
  public function getPeopleSupportedFields(){
  	return $this->restV9->getPeopleSupportedFields();
  }
  
  /*
   *  OpenSocial v0.9 People
   *  Resource: http://opensocial.myspace.com/roa/09/people/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_People
   *  Description:  Get People
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $filterby      some valid values : {topFriends | toponlineFriends | hasApp etc }
   *  @param string  $filterop      some valid values : {contains | equals etc }
   *  @param string  $filtervalue   some valid values : {true | false | specific value etc }
   *  @return object of php object representing the JSON of people
   */
  
  public function getPerson($personId, $fields=NULL, $startePage=1, $count=20, $filterby=NULL, $filterop=NULL, $filtervalue=NULL) {
  	return $this->restV9->getPerson($personId, $fields, $startePage, $count, $filterby, $filterop, $filtervalue);
  }
  
   /*
   *  OpenSocial v0.9 People
   *  Resource: http://opensocial.myspace.com/roa/09/people/@me/@friends?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_People
   *  Description:  Get Friends
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $filterby      some valid values : {topFriends | toponlineFriends | hasApp etc }
   *  @param string  $filterop      some valid values : {contains | equals etc }
   *  @param string  $filtervalue   some valid values : {true | false | specific value etc }
   *  @return object of php object representing the JSON in which a list of current user friends
   */
  
  public function getFriends($personId, $fields=NULL, $startePage=1, $count=20, $filterby=NULL, $filterop=NULL, $filtervalue=NULL) {
  	return $this->restV9->getFriends($personId, $fields, $startePage, $count, $filterby, $filterop, $filtervalue);
  }
  
  /*
   *  OpenSocial v0.9 People
   *  Resource: http://opensocial.myspace.com/roa/09/people/@me/{groupId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_People
   *  Description:  Get People By Group Id
   *  @param mixed   $personId      current Person Id
   *  @param mixed   $groupId       group Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $filterby      some valid values : {topFriends | toponlineFriends | hasApp etc }
   *  @param string  $filterop      some valid values : {contains | equals etc }
   *  @param string  $filtervalue   some valid values : {true | false | specific value etc }
   *  @return object of php object representing the JSON in which a list of current people by group Id
   */
  
  public function getPeopleByGroupId($personId, $groupId, $fields=NULL, $startePage=1, $count=20, $filterby=NULL, $filterop=NULL, $filtervalue=NULL) {
  	return $this->restV9->getPeopleByGroupId($personId, $groupId, $fields, $startePage, $count, $filterby, $filterop, $filtervalue);
  }
  
  /*
   *  OpenSocial v0.9 Notification
   *  Resource: http://opensocial.myspace.com/roa/09/notifications/@me/@self/?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_Notifications
   *  Description:  Send notification
   *  @param mixed         $personId         current Person Id
   *  @param mixed         $recipientIds     comma seperated receipient Ids
   *  @param dictionary    $templateParams   dictionary parameter
   *  @param mixed         $mediaItems       media item uri  
   *  @return object of php object representing the JSON in which a list of current media item comments
   */

   public function sendNotification($personId, $recipientIds, $templateParams, $mediaItems) {
   	 return $this->restV9->sendNotification($personId, $recipientIds, $templateParams, $mediaItems);
   }
   
   /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Update Status
   *  @param mixed   $personId         current Person Id
   *  @param mixed   $moodName         mood name like excited
   *  @param integer $mediaItem        mediaItem Id
   *  @param string  $status           status message
   *  @param string  $currentLocation  specify location
   *  @return object of php object representing the url of newly created status mood
   */
  
   public function updateStatus($personId, $moodName, $status, $currentLocation){
   	 return $this->restV9->updateStatus($personId, $moodName, $status, $currentLocation);
   }
   
   /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get StatusMood
   *  @param mixed   $personId         current Person Id
   *  @param mixed   $fields           specific fields
   *  @return object of php object representing the JSON in which the current status mood
   */

    public function getStatus($personId, $fields=NULL) {
    	return $this->restV9->getStatus($personId, $fields);
    }
    
    /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@self/history?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get StatusMood History
   *  @param mixed   $personId         current Person Id
   *  @param mixed   $fields           specific fields
   *  @return object of php object representing the JSON in which the list of status moods
   */

    public function getStatusHistory($personId, $fields=NULL) {
    	return $this->restV9->getStatusHistory($personId, $fields);
    }
    
    /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@friends/history?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get StatusMood History
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $fields        specific fields
   *  @param string  $filterby      some valid values : {topFriends | toponlineFriends | hasApp etc }
   *  @param string  $filterop      some valid values : {contains | equals etc }
   *  @param string  $filtervalue   some valid values : {true | false | specific value etc }
   *  @param bool    $includeself   current user should included or not
   *  @return object of php object representing the JSON in which the list of friends status moods
   */

    public function getFriendsStatusHistory($personId, $startePage=1, $count=20,$fields=NULL, $filterby=NULL, $filterop=NULL, $filtervalue=NULL, $includeself=NULL) {
    	return $this->restV9->getFriendsStatusHistory($personId, $startePage, $count,$fields, $filterby, $filterop, $filtervalue, $includeself);
    }
    
   /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@all/{friendId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get Friend StatusMood
   *  @param mixed   $personId      current Person Id
   *  @param integer $friendId      friend Id
   *  @param string  $fields        specific fields
   *  @return object of php object representing the JSON in which the friend status moods
   */
   
    public function getFriendsStatus($personId, $friendId, $fields=NULL) {
    	return $this->restV9->getFriendsStatus($personId, $friendId, $fields);
    }
    
    /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@all/{friendId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get Friend StatusMood History
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param integer $friendId      friend id
   *  @param string  $fields        specific fields
   *  @return object of php object representing the JSON in which the friend status mood history
   */
   
    public function getFriendStatusHistory($personId, $friendId, $startIndex=1, $count=20, $fields=NULL) {
        return $this->restV9->getFriendStatusHistory($personId, $friendId, $startIndex, $count, $fields);    
    }
    
    /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@supportedMood/{moodId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get  Supported StatusMood By Mood
   *  @param mixed   $personId      current Person Id
   *  @param integer $moodId	    mood Id
   *  @return object of php object representing the JSON in which the supported mood
   */
  
    public function getSupportedStatusById($personId, $moodId) {
    	return $this->restV9->getSupportedStatusById($personId, $moodId);
    }
    
    /*
   *  OpenSocial v0.9 StatusMood
   *  Resource: http://opensocial.myspace.com/roa/09/statusmood/@me/@supportedMood?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMood
   *  Description: Get  All Supported Mood
   *  @param mixed   $personId      current Person Id
   *  @return object of php object representing the JSON in which the list of all supported mood
   */

   public function getSupportedStatus($personId) {
   	   return $this->restV9->getSupportedStatus($personId);
   }
   
   /*
   *  OpenSocial v0.9 StatusMoodComments
   *  Resource: http://opensocial.myspace.com/roa/09/statusmoodcomments/@me/@supportedMood?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMoodComments
   *  Description: Get Status Mood Comments
   *  @param mixed   $personId      current Person Id
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @return object of php object representing the JSON in which the list of all supported mood comments
   */
   
   public function getStatusMoodComments($personId, $statusId, $startePage=1, $count=20, $fields=NULL) {
   	   return $this->restV9->getStatusMoodComments($personId, $statusId, $startePage, $count, $fields);
   }
   
    /*
   *  OpenSocial v0.9 StatusMoodComments
   *  Resource: http://opensocial.myspace.com/roa/09/statusmoodcomments/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMoodComments
   *  Description: Add Status Mood Comments
   *  @param mixed   $personId      current Person Id
   *  @param integer $statusId      Status Id
   *  @param integer $comment		comment
   *  @return object of php object representing the url of newly created statusmood comments
   */
   
   public function addStatusMoodCommentById($personId, $statusId, $comment) {
   	   return $this->restV9->addStatusMoodCommentById($personId, $statusId, $comment);
   }
   
   /*
   *  OpenSocial v0.9 StatusMoodComments
   *  Resource: http://opensocial.myspace.com/roa/09/statusmoodcomments/@me/@self?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=OpenSocial_v0.9_StatusMoodComments
   *  Description: Add Status Mood Comments By Id
   *  @param mixed   $personId      current Person Id
   *  @param integer $postedDate    mood Posted Date
   *  @param integer $comment		comment
   *  @return object of php object representing the url of newly created statusmood comments
   */
   
   public function addStatusMoodCommentByDate($personId, $postedDate, $comment) {
   	   return $this->restV9->addStatusMoodCommentByDate($personId, $postedDate, $comment);
   }
   
   /**
   * RESTurl: http://api.myspace.com/v1/user
   * Gets the MySpace UserId of the user represented by the token
   *
   * @return String value extracted from the response
   */
   public function getCurrentUserId() {
  	   return $this->restV1->getCurrentUserId(); 
   }
   
   /**
   * describes if $userId and $friendsId are currently friends
   *
   * @param String $userId
   * @param int $friendsId
   * @return object an object with a boolean that describes if $userId and $friendsId are currently friends
   */
   public function getFriendship($userId, $friendsId){
   	   return $this->restV1->getFriendship($userId, $friendsId);
   }
   
   /**
   * Puts global app data 
   * @param hash $dataHash Hash of app data to put
   */
   public function putGlobalAppData($dataHash) {
   	   return $this->restV1->putGlobalAppData($dataHash);
   }
   
   /**
   * Gets global app data
   * @param string keys Semicolon-separated keys
   * @return 
   */
   public function getGlobalAppData($keys) {
       return $this->restV1->getGlobalAppData($keys);
   }
   
   /**
   * Clears global app data identified by given keys
   * @param $keys Semicolon-separated keys
   */
   public function clearGlobalAppData($keys) {
   	   return $this->restV1->clearGlobalAppData($keys);
   }
   
   /**
   * Fetches app data of the specified keys for the friends of the given user id.
   * @param string $userId the user whose friends' app data you want
   * @param string $keys semicolon separated keys to fetch
   * @return App data requested
   */
   public function getUserFriendsAppData($userId, $keys = null) {
   	  return $this->restV1->getUserFriendsAppData($userId, $keys);
   }
   
   /**
   * Gets preference of a user
   * This is for onsite OpenSocial apps only
   * @param string $userId id of user 
   * @return Preference of user
   */
   public function getPreferences($userId) {
   	   return $this->restV1->getPreferences($userId);
   }
   
   /**
   * Gets user indicators
   * @param string $userId id of user 
   * @return User indicators
   */
  public function getIndicators($userId) {
  	  return $this->restV1->getIndicators($userId);
  }
  
  /**
   * The function will get all of the activites of a given user, provided that the current user and application have privilages to access it
   *
   * @param int|string $userId
   * @param unknown_type $culture
   * @param mixed $datetime A better limit on the activities returned is datetime because it allows the consumer to query 
   * 						deltas and only processed what has changed. Pass a date that is less than 60 days ago as the maximum and default number of days back you can query is 60. 
   * 						If you query more than that the system will only go as far back as 60. Example of querystring parameters is: datetime=06/21/2009
   * 
   * @param string $activityTypes PhotoTagged|PhotoAdd|SongUpload|ProfileSongAdd|BlogAdd|ForumPosted|ForumTopicReply|VideoAdd|ProfileVideoUpdate|FavoriteVideoAdd|FriendAdd|JoinedGroup|FriendCategoryAdd|PersonalBandShowUpdate|EventPosting|EventAttending|ApplicationAdd
   * @param int    $pageSize      You can use this parameter to specify the number of atom entries returned in the stream
   * @param bool   $composite	  Set this parameter to true to get one atom entry for all activities of the same type on the same day. If the objects of the activities go into targets then they will be grouped by target. Ex: Max uploaded 5 photos into the album Medieval Times.
   * @param bool   $extensions    Pipe delimited list of options syndicating the activity stream. Name fo the query string parameter is "extensions" Example: &extensions=actor|subject
   * 
   * @return SimpleXML a SimpleXML representation of an Activities ATOM Feed
   */
   public function getActivities($userId, $culture=null, $datetime=null, $activityTypes=null, $pageSize=null, $composite=null, $extensions=null){
   	   return $this->restV1->getActivities_ATOM($userId, $culture, $datetime, $activityTypes=null, $pageSize, $composite, $extensions);
   }
   
   /**
   * The function will get all of the activites of a given user's friends, provided that the current user and application have privilages to access it
   *
   * @param int|string $userId
   * @param unknown_type $culture
   * @param mixed $datetime A better limit on the activities returned is datetime because it allows the consumer to query 
   * 						deltas and only processed what has changed. Pass a date that is less than 60 days ago as the maximum and default number of days back you can query is 60. 
   * 						If you query more than that the system will only go as far back as 60. Example of querystring parameters is: datetime=06/21/2009
   * 
   * @param string $activityTypes PhotoTagged|PhotoAdd|SongUpload|ProfileSongAdd|BlogAdd|ForumPosted|ForumTopicReply|VideoAdd|ProfileVideoUpdate|FavoriteVideoAdd|FriendAdd|JoinedGroup|FriendCategoryAdd|PersonalBandShowUpdate|EventPosting|EventAttending|ApplicationAdd
   * @param int    $pageSize      You can use this parameter to specify the number of atom entries returned in the stream
   * @param bool   $composite	  Set this parameter to true to get one atom entry for all activities of the same type on the same day. If the objects of the activities go into targets then they will be grouped by target. Ex: Max uploaded 5 photos into the album Medieval Times.
   * @param bool   $extensions    Pipe delimited list of options syndicating the activity stream. Name fo the query string parameter is "extensions" Example: &extensions=actor|subject
   * @return SimpleXML a SimpleXML representation of an Activities ATOM Feed
   */
   public function getFriendsActivities($userId, $culture=null, $datetime=null, $activityTypes=null, $pageSize=null, $composite=null, $extensions=null){
   	   return $this->restV1->getFriendsActivities_ATOM($userId, $culture, $datetime, $activityTypes, $pageSize, $composite, $extensions);
   }
   
 
  
  /*
   *  Open Search
   *  Resource: http://api.myspace.com/opensearch/people?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Open_Search
   *  Description: Get People Search
   *  @param mixed   $searchTerms   search keywords
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $searchBy      which field the search should go through. Default is all the fields (yomi is only available to ja-jp culture) [ex. searchBy=name or searchBy=displayname or searchBy=email or searchBy=yomi] 
   *  @param string  $gender        the gender to filter on; default is no preference or both [ex. gender=m or gender=f] 
   *  @param bool    $hasPhoto      filter for those who only has photo; default is either [ex. hasPhoto=on] 
   *  @param integer $minAge        minimum age to start the search (same filter as site search) [ex. minAge=18] 
   *  @param integer $maxAge        maximum age to end the search with (same filter as site search) [ex. maxAge=68] 
   *  @param string  $location      the location field such as city state and country to search for [ex. location=US] 
   *  @param integer $distance      distance away from location to return results; default is miles; depending on culture passed in it can be kilometers [ex. distance=25] 
   *  @param mixed   $latitude 	    geo latitude to search; combination with longitude required when used [ex. latitude=1] (does not work with location field) 
   *  @param mixed   $longitude     geo longtitude to search; combination with latitude is required when used [ex. longitude=1] (does not work with location field) 
   *  @param string  $culture 		the culture context of the search; for instance japan is ja-jp; default is en-us [ex. culture=en-us] 
   *  @param string  $countryCode   countryCode to search with [ex. countryCode=CA] (this is similar to culture=en-CA) 
   *  @return object of php object representing the JSON in which the list of search
   */
  
  public function searchPeople($searchTerms, $startPage=1, $count=10, $searchBy=NULL, $gender=NULL, $hasPhoto=NULL, $minAge=NULL, $maxAge=NULL, $location=NULL, $distance=NULL, $latitude=NULL, $longitude=NULL, $culture=NULL, $countryCode=NULL) {
  	  return $this->opensearch->searchPeople($searchTerms, $startPage, $count, $searchBy, $gender, $hasPhoto, $minAge, $maxAge, $location, $distance, $latitude, $longitude, $culture, $countryCode);
  }
  
  /*
   *  Open Search
   *  Resource: http://api.myspace.com/opensearch/images?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Open_Search
   *  Description: Get Image Search
   *  @param mixed   $searchTerms   search keywords
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $searchBy      which field the search should go through. Default is all the fields (yomi is only available to ja-jp culture) [ex. searchBy=name or searchBy=displayname or searchBy=email or searchBy=yomi] 
   *  @param string  $culture 		the culture context of the search; for instance japan is ja-jp; default is en-us [ex. culture=en-us] 
   *  @param string  $sortBy        Ways to sort the images; when excluded sortBy is all [ex. sortBy=popular or sortBy=recent]
   *  @param string  $sortOrder     Order of the image sorting which can be descending (default) or ascending [ex. sortOrder=asc] 
   *  @return object of php object representing the JSON in which the list of search
   */
  
  public function searchImages($searchTerms, $startPage=1, $count=10,  $searchBy=NULL, $culture=NULL, $sortBy=NULL, $sortOrder=NULL) {
  	  return $this->opensearch->searchImages($searchTerms, $startPage, $count,  $searchBy, $culture, $sortBy, $sortOrder);
  }
  
  /*
   *  Open Search
   *  Resource: http://api.myspace.com/opensearch/video?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Open_Search
   *  Description: Get Video Search
   *  @param mixed   $searchTerms   search keywords
   *  @param integer $startIndex    Indicates the index of the first item to retrieve from the query set
   *  @param integer $count			total number of records
   *  @param string  $searchBy      which field the search should go through. Default is all the fields (yomi is only available to ja-jp culture) [ex. searchBy=name or searchBy=displayname or searchBy=email or searchBy=yomi] 
   *  @param string  $culture 		the culture context of the search; for instance japan is ja-jp; default is en-us [ex. culture=en-us] 
   *  @param string  $tag           Determine if this is a tag search [ex. tag=1] 
   *  @param string  $videomode     Determine if this is a tag search [ex. videoMode=1 (music videos) or videoMode=2 (official)] 
   *  @return object of php object representing the JSON in which the list of search
   */
  
  public function searchVideos($searchTerms, $startPage=1, $count=10, $searchBy=NULL, $culture=NULL, $tag=NULL, $videoMode=NULL) {
  	  return $this->opensearch->searchVideos($searchTerms, $startPage, $count, $searchBy, $culture, $tag, $videoMode);
  }
  
   /*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Add Subscription
   *  Subscription Usage : addSubscriptionV9('All','http://myspace.mycompany.com/handler.ashx','{}','',1,1);
   *  @return object of php object representing the url of newly created subscription
   */
  
   public function addSubscription($type, $endPoint, $query, $metaData, $batchSize, $rate, $userAddList=NULL, $userRemoveList=NULL){
   	   return $this->realStream->addSubscription($type, $endPoint, $query, $metaData, $batchSize, $rate, $userAddList, $userRemoveList);
   }
   
    /*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription/{subscriptionId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Updated Subscription
   *  Subscription Usage : updateSubscriptionV9('1234', 'All','http://myspace.mycompany.com/handler.ashx','{}','',1,1);
   *  @return object of php object representing the url of newly created subscription
   */
    
   public function updateSubscription($subscriptionId, $type, $endPoint, $query, $metaData, $batchSize, $rate, $userList, $status='Active'){
   	   return $this->realStream->updateSubscription($subscriptionId, $type, $endPoint, $query, $metaData, $batchSize, $rate, $userList, $status);
   }
   
   
   /*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription/{subscriptionId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Updated Subscription
   *  @param  integer  $subscriptionId  subscription Id
   *  @return object of php object representing the JSON in which the current user subscription
   */  
      
	public function getSubscription($subscriptionId){
		return $this->realStream->getSubscription($subscriptionId);
	}
	
	 /*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription/{subscriptionId}?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Delete Subscription
   *  @param  integer  $subscriptionId  subscription Id
   *  @return bool
   */
    
    public function deleteSubscription($subscriptionId) {
    	return $this->realStream->deleteSubscription($subscriptionId);
    }
    
    /*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription/@all?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Get All Subscription
   *  @param  integer  $subscriptionId  subscription Id
   *  @return object of php object representing the JSON in which the lost of current user subscriptions
   */
    
	public function getAllSubscription(){
		return $this->realStream->getAllSubscription();
	}
	
	/*
   *  Real Time Stream
   *  Resource: http://api.myspace.com/stream/subscription/@all?
   *  Details:  http://wiki.developer.myspace.com/index.php?title=Category:Real_Time_Stream
   *  Description: Delete All Subscription
   *  @param  integer  $subscriptionId  subscription Id
   *  @return bool
   */
    
    public function deleteAllSubscription() {
    	return $this->realStream->deleteAllSubscription();
    }
    
    /**
    * Portable contacts call to get person.  
    * @param string $fields Fields to retrieve
    * @return Person being fetched
    */
    public function getPersonPoco($personId, $fields=NULL) {
   	    return $this->portableContact->getPersonPoco($personId, $fields);
    }
    
    /**
    * Portable contacts call to get friends.  
    * @param string $startIndex First item to retrieve; defaults to 1 if not given
    * @param string $count Numer of items to retrieve; defaults to 10 if not given
    * @return Friends being fetched
    */
    public function getFriendsPoco($personId, $startIndex=1, $count=10) {
    	return $this->portableContact->getFriendsPoco($personId, $startIndex, $count);
    }
    
    /**
     * Get Access Token
     */
	
    public function getAccessToken($token=NULL) {
    	return $this->context->getAccessToken($token);
    }
    
    /**
     * Get Request Token
     */
    
    public function getRequestToken($callbackUrl) {
    	return $this->context->getRequestToken($callbackUrl);
    }
    
    /**
     * Get Authorize URL
     */
    
     public function getAuthorizeURL($token) {
     	return $this->context->getAuthorizeURL($token);
     }
    
}


?>